package com.jswdwsx.leetcode

class IsPalindrome234 {
}


class ListNode(var `val`: Int) {
    var next: ListNode? = null
}

class Solution {
    fun isPalindrome(head: ListNode?): Boolean {
        val list = ArrayList<Int>()
        var currentNode = head
        while (currentNode != null) {
            list.add(currentNode.`val`)
            currentNode = currentNode.next
        }

        var front = 0
        var back: Int = list.size - 1

        while (front < back) {
            if (list[front] != list[back]) {
                return false;
            }
            front++
            back--
        }
        return true
    }
}